package com.xinxin.leetcode.problem645;

import com.xinxin.leetcode.common.CommonUtil;

import java.util.Arrays;

/**
 * @author ShiXinXin
 * @date 2020-02-14 23:34
 */
class Solution {

    public int[] findErrorNums(int[] nums) {
        int[] arr = new int[nums.length + 1];
        int[] res = new int[2];
        for (int num : nums) {
            arr[num]++;
        }
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] == 2) {
                res[0] = i;
            } else if (arr[i] == 0) {
                res[1] = i;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(new Solution().findErrorNums(CommonUtil.createArr(1, 2, 2, 4))));
    }
}
